package com.nuc.bigdata.api.controller;

import com.nuc.bigdata.annotation.ResponseResult;
import com.nuc.bigdata.app.service.HomeViewPagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页轮播图controller，与前端交互
 * @author JackLuo
 * @date 2019/11/14
 */
@RestController
@RequestMapping("/front")
@CrossOrigin
public class HomeViewPagerController {

    private final HomeViewPagerService hvpService;

    @Autowired
    HomeViewPagerController(HomeViewPagerService hvpService) {
        this.hvpService = hvpService;
    }

    /**
     * 获取首页轮播图
     * @return 这里经过ResponseResult注解包装，返回的是Result类型，为了能兼容Service返回类型，就使用了Object类型
     */
    @GetMapping("/viewpagers")
    @ResponseResult
    public Object getAllHomeViewPagers() {
        return hvpService.getAll();
    }
}
